package com.tdd.api.server.controller;


import com.tdd.api.server.adapter.CrmApiService;
import com.tdd.api.server.domain.param.wx.app.UserOpenIdParam;
import com.tdd.api.server.domain.result.wx.service.PushReturn;
import com.tdd.api.server.entity.TbUserOpen;
import com.tdd.api.server.service.ITbUserOpenService;
import com.tdd.api.server.service.IWeChatService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author shaozq
 * @version V1.0.0
 * @description:${Description}
 * @date 2019/11/20 16:12
 * @copyright Copyright © 2019
 */
@Slf4j
@RestController
@Api(tags = "测试")
@RequestMapping("/test")
public class TestController {

    @Resource
    private CrmApiService crmApiService;

    @Resource
    private IWeChatService weChatService;

    @Resource
    private ITbUserOpenService userOpenService;


    @PostMapping("/t1")
    @ResponseBody
    public Object t1() {
        return crmApiService.getApprovalList("6bd15641147515004afa793557e5c1f7");
    }

    @GetMapping("/t2")
    @ApiOperation(value = "推送")
    @ResponseBody
    public Object t2(@RequestParam String openId) {
        PushReturn re = weChatService.pushExamineMessage(openId,
                "有一条审批，请注意查收",
                "审批测试",
                "TDD",
                "20250-02-14 12:00:00");
        if(re!=null && re.getErrcode() == 0){
            TbUserOpen user =  userOpenService.selectByUserId("4");
            user.setPushStatus(9);
            userOpenService.updateById(user);
        }
        return re;
    }

    @GetMapping("/t3")
    @ApiOperation(value = "获取用户信息")
    @ResponseBody
    public Object t3(@RequestParam String  userId) {
        return userOpenService.selectByUserId(userId);
    }

}
